package org.practice.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Inheritance(strategy=InheritanceType.JOINED)//继承映射注解 ，连接子类，对应joined-subclass，子表的主键字段同时维护外键关系
@Table(name="shop_product")
public class Product implements java.io.Serializable{
	private static final long serialVersionUID = 11222L;
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)//指定生成器的策略
	private Integer id;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="category_id",nullable=false)
	private Category category;

	@Column(name="product_name")
	private String name;

	private String description;

	@Column(name="add_time")
	private Long addTime;

	@Column(name="fixed_price",nullable=false,precision=22,scale=0)
	private double fixedPrice;

	@Column(name="dang_price")
	private double dangPrice;

	private String keywords;

	@Column(name="has_deleted")
	private Integer hasDeleted;

	@Column(name="product_pic")
	private String pic;
	
	public Product(){
		super();
	}
	
	//该构造子给hibernate用，作为购物车的信息
	public Product(Integer id, String name, double fixedPrice,double dangPrice) {
		this.id = id;
		this.name = name;
		this.fixedPrice = fixedPrice;
		this.dangPrice = dangPrice;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Long getAddTime() {
		return addTime;
	}
	public void setAddTime(Long addTime) {
		this.addTime = addTime;
	}
	public double getFixedPrice() {
		return fixedPrice;
	}
	public void setFixedPrice(double fixedPrice) {
		this.fixedPrice = fixedPrice;
	}
	public double getDangPrice() {
		return dangPrice;
	}
	public void setDangPrice(double dangPrice) {
		this.dangPrice = dangPrice;
	}
	public String getKeywords() {
		return keywords;
	}
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}
	public Integer getHasDeleted() {
		return hasDeleted;
	}
	public void setHasDeleted(Integer hasDeleted) {
		this.hasDeleted = hasDeleted;
	}
	public String getPic() {
		return pic;
	}
	public void setPic(String pic) {
		this.pic = pic;
	}

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}
	
}
